import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-09-22
 * Time: 17:32
 */

//内存可见性
public class Demo12 {
    private static volatile int isQuit=0;
    public static void main(String[] args) {
        Thread t1=new Thread(() ->{
            while(isQuit==0){
                ;
            }
            System.out.println("t1 执行结束");
        });

        Thread t2=new Thread(() ->{
            Scanner scanner=new Scanner(System.in);
            System.out.println("请输入 isQuit的值");
            isQuit=scanner.nextInt();
        });
        t1.start();
        t2.start();
    }
}
